How to work with OpenSSL for Rust within a Windows env


Pasted image 20230422133245.png|400

Pasted image 20230422135041.png|400^sfliedi

error: failed to run custom build command for `openssl-sys v0.9.85`

Caused by:
  process didn't exit successfully: `/home/chltm/workspace/axum-full-course/target/debug/build/openssl-sys-68869c6e092d43e9/build-script-main` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
...
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  run pkg_config fail: `PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" "pkg-config" "--libs" "--cflags" "openssl"` did not exit successfully: exit status: 1
  error: could not find system library 'openssl' required by the 'openssl-sys' crate

  --- stderr
  Package openssl was not found in the pkg-config search path.
  Perhaps you should add the directory containing `openssl.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'openssl' found


  --- stderr
  thread 'main' panicked at '

  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.

  If you're in a situation where you think the directory *should* be found
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
  and include information about your system as well as this message.

  $HOST = x86_64-unknown-linux-gnu
  $TARGET = x86_64-unknown-linux-gnu
  openssl-sys = 0.9.85
...

thread 'main' panicked at 'OpenSSL libdir at `["/mnt/c/vcpkg/installed/x64-windows-static/lib"]` does not contain the required files to either statically or dynamically link OpenSSL', /home/chltm/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.85/build/main.rs:403:13

^xm109w
Pasted image 20230422222134.png